<script>
import { getBannerList, delBannerList } from '@/api//banner'
// import { ElMessage } from 'element-plus'

export default {
  name: 'bannerlist',
  data() {
    return {
      bannerList: []
    }
  },
  mounted() {
    getBannerList().then(res => {
      // console.log(res)
      this.bannerList = res.data
    })
  },
  methods: {
    //删除按钮的点击事件
    handleDelete(row) {
      // console.log(row)
      delBannerList({ bannerid: row.bannerid }).then(res => {
        if (res.code === '200') {
          console.log(res)
          getBannerList().then(res => {
            // 获取请求的数据
            // console.log(res)
            this.bannerList = res.data
          })
        }
      })
    }
  }
}
</script>

<template>
  <div>
    轮播图列表
    <el-table :data="bannerList">
      <el-table-column type="index" label="序号" width="60px" align="center"></el-table-column>
      <el-table-column prop="img" label="图片" align="center">
        <template #default="scope">
          <el-image :src="scope.row.img"></el-image>
        </template>
      </el-table-column>
      <el-table-column prop="alt" label="提示信息" align="center"></el-table-column>
      <el-table-column prop="link" label="链接" align="center"></el-table-column>
      <el-table-column label="删除数据" align="center">
        <template #default="scope">
          <el-button type="danger" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<style lang="scss" scoped>
.el-image {
  width: 100px;
}
</style>